.class public Lcom/adview/adapters/SmaatoAdapter;
.super Lcom/adview/adapters/AdViewAdapter;
.source "SmaatoAdapter.java"

# interfaces
.implements Lcom/smaato/SOMA/AdListener;


# instance fields
.field private banner:Lcom/smaato/SOMA/SOMABanner;


# direct methods
.method public constructor <init>(Lcom/adview/AdViewLayout;Lcom/adview/obj/Ration;)V
    .locals 1
    .parameter "adViewLayout"
    .parameter "ration"

    .prologue
    .line 23
    invoke-direct {p0, p1, p2}, Lcom/adview/adapters/AdViewAdapter;-><init>(Lcom/adview/AdViewLayout;Lcom/adview/obj/Ration;)V

    .line 21
    const/4 v0, 0x0

    iput-object v0, p0, Lcom/adview/adapters/SmaatoAdapter;->banner:Lcom/smaato/SOMA/SOMABanner;

    .line 25
    return-void
.end method


# virtual methods
.method public handle()V
    .locals 5

    .prologue
    .line 30
    iget-object v3, p0, Lcom/adview/adapters/SmaatoAdapter;->adViewLayoutReference:Ljava/lang/ref/WeakReference;

    invoke-virtual {v3}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lcom/adview/AdViewLayout;

    .line 31
    .local v1, adViewLayout:Lcom/adview/AdViewLayout;
    if-nez v1, :cond_1

    .line 52
    :cond_0
    :goto_0
    return-void

    .line 35
    :cond_1
    :try_start_0
    iget-object v3, v1, Lcom/adview/AdViewLayout;->activityReference:Ljava/lang/ref/WeakReference;

    invoke-virtual {v3}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/app/Activity;

    .line 36
    .local v0, activity:Landroid/app/Activity;
    if-eqz v0, :cond_0

    .line 39
    new-instance v3, Lcom/smaato/SOMA/SOMABanner;

    invoke-direct {v3, v0}, Lcom/smaato/SOMA/SOMABanner;-><init>(Landroid/content/Context;)V

    iput-object v3, p0, Lcom/adview/adapters/SmaatoAdapter;->banner:Lcom/smaato/SOMA/SOMABanner;

    .line 40
    iget-object v3, p0, Lcom/adview/adapters/SmaatoAdapter;->banner:Lcom/smaato/SOMA/SOMABanner;

    invoke-virtual {v3, p0}, Lcom/smaato/SOMA/SOMABanner;->addAdListener(Lcom/smaato/SOMA/AdListener;)V

    .line 41
    iget-object v3, p0, Lcom/adview/adapters/SmaatoAdapter;->banner:Lcom/smaato/SOMA/SOMABanner;

    iget-object v4, p0, Lcom/adview/adapters/SmaatoAdapter;->ration:Lcom/adview/obj/Ration;

    iget-object v4, v4, Lcom/adview/obj/Ration;->key:Ljava/lang/String;

    invoke-static {v4}, Ljava/lang/Integer;->valueOf(Ljava/lang/String;)Ljava/lang/Integer;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/Integer;->intValue()I

    move-result v4

    invoke-virtual {v3, v4}, Lcom/smaato/SOMA/SOMABanner;->setPublisherId(I)V

    .line 42
    iget-object v3, p0, Lcom/adview/adapters/SmaatoAdapter;->banner:Lcom/smaato/SOMA/SOMABanner;

    iget-object v4, p0, Lcom/adview/adapters/SmaatoAdapter;->ration:Lcom/adview/obj/Ration;

    iget-object v4, v4, Lcom/adview/obj/Ration;->key2:Ljava/lang/String;

    invoke-static {v4}, Ljava/lang/Integer;->valueOf(Ljava/lang/String;)Ljava/lang/Integer;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/Integer;->intValue()I

    move-result v4

    invoke-virtual {v3, v4}, Lcom/smaato/SOMA/SOMABanner;->setAdSpaceId(I)V

    .line 43
    iget-object v3, p0, Lcom/adview/adapters/SmaatoAdapter;->banner:Lcom/smaato/SOMA/SOMABanner;

    invoke-virtual {v3}, Lcom/smaato/SOMA/SOMABanner;->asyncLoadNewBanner()V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    .line 47
    .end local v0           #activity:Landroid/app/Activity;
    :catch_0
    move-exception v3

    move-object v2, v3

    .line 48
    .local v2, e:Ljava/lang/Exception;
    invoke-virtual {v1}, Lcom/adview/AdViewLayout;->rollover()V

    goto :goto_0
.end method

.method public onFailedToReceiveAd(Lcom/smaato/SOMA/AdDownloader;Lcom/smaato/SOMA/ErrorCode;)V
    .locals 3
    .parameter "arg0"
    .parameter "arg1"

    .prologue
    .line 57
    invoke-static {}, Lcom/adview/AdViewTargeting;->getRunMode()Lcom/adview/AdViewTargeting$RunMode;

    move-result-object v1

    sget-object v2, Lcom/adview/AdViewTargeting$RunMode;->TEST:Lcom/adview/AdViewTargeting$RunMode;

    if-ne v1, v2, :cond_0

    .line 58
    const-string v1, "AdView SDK v1.7.0"

    const-string v2, "Smaato fail"

    invoke-static {v1, v2}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 59
    :cond_0
    iget-object v1, p0, Lcom/adview/adapters/SmaatoAdapter;->banner:Lcom/smaato/SOMA/SOMABanner;

    invoke-virtual {v1, p0}, Lcom/smaato/SOMA/SOMABanner;->removeAdListener(Lcom/smaato/SOMA/AdListener;)V

    .line 60
    iget-object v1, p0, Lcom/adview/adapters/SmaatoAdapter;->adViewLayoutReference:Ljava/lang/ref/WeakReference;

    invoke-virtual {v1}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/adview/AdViewLayout;

    .line 61
    .local v0, adViewLayout:Lcom/adview/AdViewLayout;
    if-nez v0, :cond_1

    .line 67
    :goto_0
    return-void

    .line 64
    :cond_1
    iget-object v1, v0, Lcom/adview/AdViewLayout;->adViewManager:Lcom/adview/AdViewManager;

    invoke-virtual {v1}, Lcom/adview/AdViewManager;->resetRollover_pri()V

    .line 65
    invoke-virtual {v0}, Lcom/adview/AdViewLayout;->rotateThreadedPri()V

    goto :goto_0
.end method

.method public onReceiveAd(Lcom/smaato/SOMA/AdDownloader;Lcom/smaato/SOMA/SOMAReceivedBanner;)V
    .locals 4
    .parameter "arg0"
    .parameter "arg1"

    .prologue
    .line 72
    invoke-static {}, Lcom/adview/AdViewTargeting;->getRunMode()Lcom/adview/AdViewTargeting$RunMode;

    move-result-object v1

    sget-object v2, Lcom/adview/AdViewTargeting$RunMode;->TEST:Lcom/adview/AdViewTargeting$RunMode;

    if-ne v1, v2, :cond_0

    .line 73
    const-string v1, "AdView SDK v1.7.0"

    const-string v2, "Smaato success"

    invoke-static {v1, v2}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 74
    :cond_0
    iget-object v1, p0, Lcom/adview/adapters/SmaatoAdapter;->banner:Lcom/smaato/SOMA/SOMABanner;

    invoke-virtual {v1, p0}, Lcom/smaato/SOMA/SOMABanner;->removeAdListener(Lcom/smaato/SOMA/AdListener;)V

    .line 76
    iget-object v1, p0, Lcom/adview/adapters/SmaatoAdapter;->adViewLayoutReference:Ljava/lang/ref/WeakReference;

    invoke-virtual {v1}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/adview/AdViewLayout;

    .line 77
    .local v0, adViewLayout:Lcom/adview/AdViewLayout;
    if-nez v0, :cond_1

    .line 84
    :goto_0
    return-void

    .line 80
    :cond_1
    iget-object v1, v0, Lcom/adview/AdViewLayout;->adViewManager:Lcom/adview/AdViewManager;

    invoke-virtual {v1}, Lcom/adview/AdViewManager;->resetRollover()V

    .line 81
    iget-object v1, v0, Lcom/adview/AdViewLayout;->handler:Landroid/os/Handler;

    new-instance v2, Lcom/adview/AdViewLayout$ViewAdRunnable;

    iget-object v3, p0, Lcom/adview/adapters/SmaatoAdapter;->banner:Lcom/smaato/SOMA/SOMABanner;

    invoke-direct {v2, v0, v3}, Lcom/adview/AdViewLayout$ViewAdRunnable;-><init>(Lcom/adview/AdViewLayout;Landroid/view/ViewGroup;)V

    invoke-virtual {v1, v2}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z

    .line 82
    invoke-virtual {v0}, Lcom/adview/AdViewLayout;->rotateThreadedDelayed()V

    goto :goto_0
.end method
